package com.cdut.logistics.service.impl.datacentre;

import java.util.List;
import com.cdut.logistics.model.dao.datacentre.Dict;
import com.cdut.logistics.service.interf.datacentre.DictService;
import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;



/**  
 * @ClassName: Dict
 * @Description: 字典值管理接口实现类  
 * @author wxt.xia
 * @date 2018年1月26日 上午9:14:27    
 */
public class DictImpl implements DictService{
	
	private Dict dao = new Dict();
	
	/**  
	 * @Title: get  
	 * @Description: 根据id查询字典值
	 * @author wxt.xia
	 * @param dict
	 * @throws  
	 */
	public Dict get(int id) {
		return dao.queryById(id);
	}
	
	/**  
	 * @Title: queryById  
	 * @Description: 根据id查询字典值
	 * @author wxt.xia
	 * @param dict
	 * @throws  
	 */
	
	public Record queryById(int id) {
		return Db.findFirst(dao.sql1,id);
	}
	/**  
	 * @Title: query  
	 * @Description: 根据name查询字典值
	 * @author wxt.xia
	 * @param dict
	 * @throws  
	 */
	public List<Record> query(String description) {
		return Db.find(dao.sql6,description);
	}

	/**  
	 * @Title: add  
	 * @Description: 新增字典值
	 * @author wxt.xia
	 * @param dict
	 * @throws  
	 */
	public void add(Dict dict){
		try {
			dao.save(dict);
		} catch (Exception e) {
			// TODO: handle exception
		}
	}

	/**  
	 * @Title: modify  
	 * @Description: 修改字典值
	 * @author wxt.xia
	 * @param dept
	 * @throws  
	 */
	public void modify(Dict dict){
		dict.update();
	}
	
	/**  
	 * @Title: remove  
	 * @Description: 删除字典值
	 * @author wxt.xia
	 * @param id
	 * @throws  
	 */
	public void remove(int id){
		dao.remove(id);
	}
}
